try {
	Type.registerNamespace('MMFlowSnUtil');
	MMFlowSnUtil.getFlowSn = function(materialvid, cbatchcode) {
		if(null == materialvid || materialvid == "") {
			$alert("物料不能为空！");
			return;
		}
		if(null == cbatchcode || cbatchcode == "") {
			$alert("批次号不能为空！");
			return;
		}
		var sn = "";
		var condition = {
			"vflowseed": "= in ('" + materialvid + cbatchcode + "')"
		};
		$js.showLoadingBar();
		loadSnData(condition, function(data) {
			if(data != null) {
				//获取本地旧数据，没有扫描数量清空
				var vocount = 0;
				var billinfos = data.billinfos;
				if(NCMMPubUtil.isNotEmpty(billinfos) && billinfos.length > 0) {
					sn = cbatchcode + billinfos[0].billinfo.head["vlastsn"];
					$js.hideLoadingBar();					
				} else {
					$js.hideLoadingBar();
					$toast("没有获取到流水号！");
				}
			} else {
				$js.hideLoadingBar();
				$toast("没有获取到流水号！");
			}
		});
		return sn;

	}

	function loadSnData(condition, callback) {
		//获取外部系统调用标识
		var docType = "Flow_Query";		
		var srvname = NCMMHttpUtil.BILL;
		//拼装HTTP请求参数
		var httpURL = NCMMHttpUtil.getQuestURL(srvname);
		var aggvo = "aggvo";
		var httpparam = NCMMHttpUtil.getHTTPRequestParam(docType, aggvo, condition);
		//发送HTTP请求	 同步
		$.ajax({
			type: 'POST',
			beforeSend: function(req) {
				req.setRequestHeader("accept", "application/json");
			},
			url: httpURL,
			"data": JSON.stringify(httpparam),
			timeout: 120000,
			async:false,
			success: function(data, status) {
				if(data == null || data == "") {
					data = {};
					data["error"] = "没有获取到NC数据。";
					if(callback != null && typeof(callback) == 'function') {
						callback(data, 2); //2： 请求成功，返回值为空
					};
				} else {
					if($isPlainObject(data) == false) {
						data = $stringToJSON(data);
					}
					if(callback != null && typeof(callback) == 'function') {
						callback(data, 1); //1：请求成功, 返回有效的response数据
					};
				}
			},
			error: function(data) {
				if(callback != null && typeof(callback) == 'function') {
					callback(data, 0); //0：请求失败，返回服务端提示的错误信息
				};
			}
		});
	};
} catch(e) {
	$e(e);
}